<template>
	<view>
		<scroll-view class="scroll-list bg-white" scroll-y="true">
			<block v-for="(ietm,index) in list" :key="index">
				<u-form class="form" :model="ietm" ref="uForm" label-position="left">
					<u-form-item label="箱码:" prop="code" label-width="120" >
						<u-input v-model="ietm.code" :disabled="true" type="text" di maxlength="64"></u-input>
						<u-icon name="/static/common/img/delData.png" @click="delData(ietm.code)" color="#2979ff" class="rights" size="30"></u-icon>
					</u-form-item>
				</u-form>
			</block>
		</scroll-view>
		<view  style="height: 65px;" ></view>
		<view class="footer">
			<view class="confrim-btn padding padding-bottom-sm  bg-white">
				<u-button type="primary" class="no-border confirm-btn" @click="submit" >确认</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
			}
		},
		onLoad() {
			var _this = this;
			const eventChannel = this.getOpenerEventChannel();
		    eventChannel.on('initfilter',function(info){
				_this.list = info;
			});
		},
		methods: {
			//提交
			submit(){
				setTimeout(() => {
				    const eventChannel = this.getOpenerEventChannel();
				    eventChannel.emit('Filter', this.list);
			    }, 300);
				uni.navigateBack();
			},
			//页面删除数据
			delData(code){
				var _this = this;
				var list = _this.list;
				for(var i = 0 ; i < list.length ; i++ ){
					if(list[i].code == code){
						if(list[i].code.length == 24){
							_this.num = parseInt(_this.num) - 1;
							_this.qty = parseInt(_this.qty) - parseInt(list[i].quty);
						}
						list.splice(i,1);
					}
				}
			},
		}
	}
</script>

<style>
@import '../../btdm.css';
.scroll-list {
	height: calc(100vh - var(--window-top) - var(--window-bottom) - 65px);
	width: 100%;
}
</style>
